#!/usr/bin/env bash
################################################################################
# CLIMAX Candy Suite UNINSTALL Script
#
# Copyright (c) 2008-2011 David Christian Liedle <david.liedle@gmail.com>
# All rights reserved. Released under the terms of the MIT Open Source License.
# Visit http://code.google.com/p/climax/ to view this project's home page/repo.
#


echo
echo "- - - WARNING! - - -
echo "This script entirely removes The CLIMAX Candy Suite from your system."
echo
echo "This script must be run with root privileges (sudo) to work."
echo "Are you SURE you want to delete the following directories?"
echo
echo "    rm -rf /usr/local/lib/climax/"
echo "    rm -rf /usr/local/candy/"
echo
echo -n "Please answer yes or no (yes to DELETE, no to cancel): "
read CXDELYN
if [ $CXDELYN = "yes" ]; then
    echo
    echo -n "Detecting installed files...."
    if [ -d /usr/local/lib/climax ]; then
        if [ -d /usr/local/candy ]; then
            echo "done."
        else
            echo "ERROR!"
            echo "I could not find /usr/local/candy, so I can't delete it!"
            echo "No changes have been made."
            exit 1
        fi
    else
        echo "ERROR!"
        echo "I could not find /usr/local/lib/climax, so I can't delete it!"
        echo "No changes have been made."
        exit 1
    fi
    echo
    echo -n "Removing all CLIMAX frameworks...."
    rm -rf /usr/local/lib/climax
    echo "DONE"
    echo -n "Removing all Candy Suite programs...."
    rm -rf /usr/local/candy
    echo "DONE"
    echo
    echo "All of The CLIMAX Candy Suite files and directories have been removed."
    echo "To finalize cleanup, remove /usr/local/candy from your PATH."
    echo "I hope you will consider installing The CLIMAX Candy Suite again soon!"
    echo "As always, the official Google Code home page is the best place for the"
    echo "very latest on The CLIMAX Candy Suite:"
    echo
    echo "    http://code.google.com/p/climax/"
    echo
    echo "Please don't hesitate to give me feedback on what you did not like about"
    echo "this software... You may email me personally at david.liedle@gmail.com"
    echo
    echo "    --David:."
    echo
    echo "goodbye."
    exit 0
else
    echo
    echo "    CANCELLED"
    echo
    echo "No changes have been made."
    echo
    exit 0
fi